﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace You.Niao.User.Area
{
    public class UserAreaRegistration:AreaRegistration
    {

        public override string AreaName
        {
            get
            {
                return "User";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            foreach (var route in GetRoutes())
                context.Routes.Add(route);
        }

        public IEnumerable<Route> GetRoutes()
        {
            return new[] { 
                new Route(
                    "User",
                    new RouteValueDictionary { { "area", AreaName }, { "controller", "User" }, { "action", "Index" }},
                    new RouteValueDictionary(),
                    new RouteValueDictionary { { "area", AreaName }},
                    new MvcRouteHandler()
                )
                ,
                new Route(   //默认
                    "User/{action}/{id}",
                    new RouteValueDictionary { { "area", AreaName }, { "controller", "User" }, { "action", "Index" },{"id",""} },
                    new RouteValueDictionary(),
                    new RouteValueDictionary { { "area", AreaName }},
                    new MvcRouteHandler()
                ),
                 new Route(
                    "UserAPI",
                    new RouteValueDictionary { { "area", AreaName }, { "controller", "UserAPI" }, { "action", "Index" }},
                    new RouteValueDictionary(),
                    new RouteValueDictionary { { "area", AreaName }},
                    new MvcRouteHandler()
                )
                ,
                new Route(   //默认
                    "UserAPI/{action}/{id}",
                    new RouteValueDictionary { { "area", AreaName }, { "controller", "UserAPI" }, { "action", "Index" },{"id",""} },
                    new RouteValueDictionary(),
                    new RouteValueDictionary { { "area", AreaName }},
                    new MvcRouteHandler()
                )  


            };

        }

 

    }
}